package com.woniu.his.sms.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.woniu.his.exception.HisException;
import com.woniu.his.sms.common.SmsResultCode;
import com.woniu.his.sms.common.enums.SmsStatusEnums;
import com.woniu.his.sms.infra.model.DeptType;
import com.woniu.his.sms.infra.mapper.DeptTypeMapper;
import com.woniu.his.sms.service.DeptTypeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 科室类别表 服务实现类
 * </p>
 *
 * @author cb
 * @since 2022-11-25
 */
@Service
public class DeptTypeServiceImpl extends ServiceImpl<DeptTypeMapper, DeptType> implements DeptTypeService {

    /**
     * 添加科室类型
     *
     * @param deptTypeName 科室类型名称
     */
    @Override
    public void addDeptType(String deptTypeName) {

        QueryWrapper<DeptType> wrapper=new QueryWrapper<>();
        wrapper.eq("dept_type_name",deptTypeName);
        DeptType one = getOne(wrapper);
        if (one != null) throw new HisException(SmsResultCode.DEPT_TYPE_IS_EXIST);
        DeptType type=new DeptType();
        type.setDeptTypeName(deptTypeName);
        type.setDeptTypeStatus(SmsStatusEnums.ON.getCode());
        save(type);
    }

}
